/*  
 * Copyright 2007 MBARI 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */
package org.mbari.timeline.swing;

import java.util.Comparator;

import com.domainlanguage.time.Duration;
import com.domainlanguage.time.TimePoint;

/** 
 * @author Andrew Chase
 */
public enum TableDisplayNames {
	name("Name", String.class, new StringComparator()), //
	time("Start Time", TimePoint.class, new TimePointComparator()), //
	duration1("First Duration", Duration.class, new DurationComparator()), // 
	duration2("Second Duration", Duration.class, new DurationComparator());

	public final String text;
	public final Class clazz;
	public final Comparator comparator;

	private TableDisplayNames(String text, Class clazz, Comparator comparator) {
		this.text = text;
		this.clazz = clazz;
		this.comparator = comparator;
	}

}

class StringComparator implements Comparator {
	public int compare(Object o1, Object o2) {
		String s1 = (String) o1;
		String s2 = (String) o2;
		return s1.compareToIgnoreCase(s2);
	}

}

class TimePointComparator implements Comparator<TimePoint> {
	public int compare(TimePoint o1, TimePoint o2) {
		return o1.compareTo(o2);
	}

}

class DurationComparator implements Comparator<Duration> {
	public int compare(Duration o1, Duration o2) {
		return o1.compareTo(o2);
	}

}
